package chapter3.No3_2_方法join的使用.demo6;

/**
 * Created by Administrator on 2016/11/20.
 */
public class ThreadA extends Thread {

    @Override
    public void run() {
        synchronized (this) {
            try {
                System.out.println(Thread.currentThread().getName()+"霸占A线程1秒钟开始");
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName()+"霸占A线程1秒钟结束，用join释放掉！");
                join();
                System.out.println(Thread.currentThread().getName()+"join后面的代码！");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }

    public synchronized void methodA() {
        System.out.println(Thread.currentThread().getName()+" 线程调用：methodA获取对象锁!"+System.currentTimeMillis());
    }

}
